<template>
  <d2-container class="tasklist">
    <template slot="header">统计</template>
    <div style="display:flex;flex-direction: column;">
      <div style="display:flex;margin-top:20px;margin-bottom:20px;">
        <el-date-picker end-placeholder="结束日期" range-separator="至" start-placeholder="开始日期"
                        type="datetimerange" value-format="yyyy-MM-dd HH:mm:ss"
                        v-model="value1">
        </el-date-picker>
        <el-input v-model="input" style="width:200px;margin-left:10px;" placeholder="请输入店铺名称"></el-input>
        <el-input v-model="inputID" style="width:200px;margin-left:10px;" placeholder="请输入宝贝id"></el-input>
        <el-input v-model="input_invite" style="width:200px;margin-left:10px;" placeholder="请输入邀请人"></el-input>
        <el-button type="primary" style="margin-left:10px;" @click="dailystatistic_Serach()">查询</el-button>
      </div>
    </div>
    <el-table
      :data="tableData"
      show-summary
      border
      style="width: 100%;overflow-x:scroll;">
      <el-table-column
        prop="agent_name"
        align="center"
        label="邀请人账户名">
      </el-table-column>
      <el-table-column
        prop="consumption_money"
        align="center"
        width="120"
        label="支付平台总佣金">
      </el-table-column>
      <el-table-column
        prop="commission_money"
        align="center"
        label="邀请人提成">
      </el-table-column>
      <el-table-column
        prop="order"
        align="center"
        label="订单表">
      </el-table-column>
      <el-table-column
        prop="price"
        align="center"
        label="支付金额">
      </el-table-column>
      <el-table-column
        prop="shopname"
        align="center"
        label="店铺名">
      </el-table-column>
      <el-table-column
        prop="link"
        align="center"
        label="宝贝id">
      </el-table-column>
      <el-table-column
        prop="task_yjmoney"
        align="center"
        label="刷手佣金">
      </el-table-column>
      <el-table-column
        prop="task_superior"
        align="center"
        label="师傅佣金">
      </el-table-column>
      <el-table-column
        prop="task_levelthree"
        align="center"
        label="师公佣金">
      </el-table-column>
      <el-table-column
        prop="profit"
        align="center"
        label="每单利润">
      </el-table-column>
      <el-table-column
        prop="create_time"
        width="160"
        align="center"
        label="创建时间">
      </el-table-column>
      <!--      <el-table-column-->
      <!--        align="center"-->
      <!--        label="更新">-->
      <!--        <template slot-scope="scope">-->
      <!--          <el-button type="primary" @click="dailystatistic_unload(scope.row)">更新</el-button>-->
      <!--        </template>-->
      <!--      </el-table-column>-->
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      :current-page.sync="page"
      @current-change="handleCurrentChange"
      :page-sizes="[50, 100, 200, 300]"
      :page-size="50"
      layout="total, sizes, prev, pager, next, jumper"
      :total="Number(count)">
    </el-pagination>
  </d2-container>
</template>

<script>
  import {dailystatistics, dateList} from '@api/sys.login'
  export default {
    name: "statistics",
    data() {
      return {
        tableData: [],
        input: "",
        value1: "",
        inputID: "",
        input_invite: "",
        count: "",
        valueing: "",
        pagesize:10,
        page: 1,
        timer: new Date().getTime() / 1000
      }
    },
    methods: {
      handleSizeChange(val) {
        this.pagesize = val
        this.dailystatistic_Serach()
      },
      //分页
      handleCurrentChange(val) {
        this.page = val
        this.dailystatistic_Serach()
      },
      //列表
      dailystatistic_Serach() {
        dateList(this.value1[0], this.page, this.pagesize, this.value1[1], this.input, this.inputID, this.input_invite).then((res) => {
          this.tableData = res.list.map((item) => {
            this.$set(item, 'profit',(item.consumption_money - item.commission_money - item.task_yjmoney - item.task_superior - item.task_levelthree).toFixed(2))
            return item
          })
          this.count = res.count
        })
      },
    },
    created() {
      this.dailystatistic_Serach()
    }
  }
</script>

<style>
</style>
